﻿namespace Hrunga.PVCM.Framework.Helpers
{
    /// <summary>
    /// Wrapper to a view to automatically initialize the presenter 
    /// </summary>
    /// <typeparam name="TPresenter">The type of the presenter.</typeparam>
    /// <typeparam name="TView">The type of the view.</typeparam>
    public partial class ViewWrapper<TPresenter, TView>
        where TPresenter : IPresenter<TView>, new()
        where TView : IView
    {
        private readonly TPresenter presenter;
        private readonly TView form;

        /// <summary>
        /// Initializes a new instance of the <see cref="ViewWrapper&lt;TPresenter, TView&gt;"/> class.
        /// </summary>
        /// <param name="form">The form.</param>
        public ViewWrapper(TView form)
        {
            this.form = form;
            this.presenter = new TPresenter();
            this.presenter.Initialize(this.form);
        }
    }
}